package com.atguigu.gmall.user.controller;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.common.util.IpUtil;
import com.atguigu.gmall.model.user.UserInfo;
import com.atguigu.gmall.model.vo.user.LoginUserResponseVo;
import com.atguigu.gmall.user.service.UserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;

/**
 * @author A
 * @version 1.0
 * @description: TODO
 * @date 2025/9/11 22:44
 */
@RestController
@RequestMapping("/api/user")
public class RejisteController {
    @Autowired
    UserInfoService userInfoService;
    @PostMapping("/passport/register")
    public Result<LoginUserResponseVo> register(@Valid @RequestBody UserInfo userInfo, HttpServletRequest request) {
        String ipAddress = IpUtil.getIpAddress(request);
        userInfo.setIpAddress(ipAddress);
        LoginUserResponseVo responseVo=userInfoService.register(userInfo);
        return Result.ok(responseVo);
    }
}
